package sis.studentinfo;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: Alex
 * Date: 26.08.12
 * Time: 13:53
 * To change this template use File | Settings | File Templates.
 */
public class CourseSession {
    public static final String NEWLINE = System.getProperty("line.separator");
    private String department;
    private String number;
    private ArrayList<Student> students = new ArrayList<Student>();
    private Date startDate;

    public static final String ROSTER_REPORT_HEADER = "Student" + NEWLINE + "-" + NEWLINE;
    public static final String ROSTER_REPORT_FOOTER = NEWLINE + "# students = ";


    public CourseSession(String department, String number, Date startDate)
    {
        this.department = department;
        this.number = number;
        this.startDate = startDate;
    }

    public String getDepartment() {
        return department;
    }

    public String getNumber() {
        return number;
    }

    public int getNumberOfStudents() {
        return students.size();
    }

    public void enroll(Student student) {

        students.add(student);
    }

    public Student get(int i) {
        return students.get(i);
    }

    public Date getEndDate()
    {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(startDate);
        // weeks * days per week - 3 days
        final int sessionLength = 16;
        final int daysInWeek = 7;
        final int daysFromFridayToMonday = 3;
        int numberOfDays = sessionLength * daysInWeek - daysFromFridayToMonday;
        calendar.add(Calendar.DAY_OF_YEAR, numberOfDays);

        return calendar.getTime();
    }

    public Date getStartDate() {
        return startDate;
    }

    public ArrayList<Student> getAllStudents() {
        return students;
    }
}
